HAL SRAM migration: List of applicable concepts

This section provides information about the HAL SRAM applicable architecture concepts.

Concepts for SRAM

Concept

Description

Separation of initialization and configuration functions

The HAL_SRAM_Init() has been split to:

  • HAL_SRAM_Init() initializes the handle and links it to a SRAM instance.

  • HAL_SRAM_SetConfig(): configures the FMC peripheral.

  • HAL_SRAM_SetConfigxxxMemory(): configures the memories with different access mode.

Removal and conversion of init structure to configuration structure

The init structure NORSRAM_InitTypeDef is removed from the handle and converted into:

  • hal_sram_config_t: static configuration.

  • hal_sram_xxx_memory_config_t: one of the four memory-specific.

Renaming of the handle structure

The handle structure SRAM_HandleTypeDef has been renamed to hal_sram_handle_t.

Renaming unitary init structures

The init structure NORSRAM_InitTypeDef is no longer available. It has been replaced by hal_sram_config_t, hal_sram_xxx_timings_config_t and hal_sram_xxx_memory_config_t.

Remove MspInit and MspDeInit callbacks

The HAL_SRAM_MspInit() and HAL_SRAM_MspDeInit() are no longer available, they are replaced by a user sequence to initializes and configures the SRAM.

Introduction of HAL user data set/get APIs

Two functions to set and get user data are available: HAL_SRAM_SetUserData() and HAL_SRAM_GetUserData().

Revised and optimized HAL state machine

The SRAM state machine has been revised as follows:

  • The protected state HAL_SRAM_STATE_PROTECTED has been removed.

  • The configured states HAL_SRAM_STATE_CONFIGURED and HAL_SRAM_STATE_MEMORY_CONFIGURED have been added.

Revised and optimized HAL API status returns

The input parameter checks using assertions have been added to the APIs.

Replaced TypeDef suffix with _t in type names

All TypeDef parts of the HAL SRAM driver have been removed and replaced by _t.

Replaced nonmodifiable pointers with const keywords

Const keywords have been added to non-modifiable pointers to ensure that either the pointer itself or the data it points to cannot be modified. This enhances code safety and readability, prevents unintended modifications, and renders code more robust and maintainable.

Assertion implementation and usage in HAL1

The parameters and state are checked using ASSERT_DBG_STATE and ASSERT_DBG_PARAM macros.

Rename LL core drivers to stm32_ppp_core.h/.c to avoid confusion with user LL drivers.

The core driver name is changed from stm32_ll_ppp.h/.c to stm32_ppp_core.h/.c ( stm32_fmc_core.h/.c).

Add HAL PPP Services for Drivers with Handle to Retrieve Corresponding Peripheral Clock Frequency.

The HAL SRAM driver provides a new API to retrieve the clock frequency: HAL_SRAM_GetClockFreq().

Replace Finite Parameter Defines (Including PPP Instances) with Enum Types at HAL Levels.

Finite parameters (including SRAM instances) have been converted into enumerated types (enums) at HAL level. This improves code readability, maintainability, and type safety.

Replace the assert_param macro with ASSERT_DBG_PARAM, controlled by the USE_ASSERT_DBG_PARAM conditional.

The conditional compilation flag USE_ASSERT_DBG_PARAM is introduced to enable or disable debug parameter assertions.

Add ASSERT_DBG_STATE macro controlled by USE_ASSERT_DBG_STATE conditional.

The conditional compilation flag USE_ASSERT_DBG_STATE is introduced to enable or disable debug parameter assertions.

Other HAL SRAM changes

Concept

Consideration

Use the sub-bank as the unitary instance instead of providing the base address and the bank offset

The new enumeration hal_sram_t has been added to select one of the four sub-banks of bank1 ( HAL_SRAM1, HAL_SRAM2, HAL_SRAM3, HAL_SRAM4) as SRAM instance with no bank selection.

Split the configuration into Static configuration structure and Memory configuration structures

The HAL_SRAM_SetConfig() is called, then configure the memory HAL_SRAM_SetConfigxxxMemory(), and optionally HAL_SRAM_SetWrAsyncTimings() before use:

  • hal_sram_config_t configures static FMC parameters.

  • hal_sram_xxx_memory_config_t sets memory-specifics and the timings.

  • hal_sram_wr_async_timings_t is used if write async timings differ.

Add SRAM write protection state in the handle

The hal_sram_wr_protection_status_t is added in the handle to check the write protection status:

  • HAL_SRAM_WR_NOT_PROTECTED.

  • HAL_SRAM_WR_PROTECTED.

Remove WriteOperation from SRAM configuration structure

When needed the user call directly the corresponding API. The WriteOperation is removed from configuration, the write protection is enabled by default.

Remove process APIs as they depends of user application

There is no specific FMC hardware configuration needed for DMA requests, as read and write operations are directly accessible by the user.

Add API to check the status of write protection

HAL_SRAM_IsEnabledWriteProtection() to check the protection state.

Change timing parameters unit from cycle to ns

The static API is added to convert these values before setting them in the FMC register.

Remove __HAL_LINKDMA generic macro

DMA functionality is separated from SRAM because the memory is memory-mapped and does not require dedicated DMA handling.

Remove extended mode NORSRAM_EXTENDED_TypeDef

Bank1 is selected directly without requiring explicit , the instance will be used to sub-banks.